<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>监听</button>
    <button>方法监听</button>
    <button>ie9</button>
    <script>
        var btns = document.querySelectorAll("button");
        btns[0].onclick = function() {
            alert("hi");
        }
        btns[0].onclick = function() {
                alert("hi nihao");
            }
            //方法监听
        btns[1].addEventListener("click", function() {
            alert(22);
        })
        btns[1].addEventListener("click", function() {
                alert(33);
            })
            //3.
        btns[2].attachEvent("onclick", function() {
            alert(77);
        })
    </script>
</body>

</html>